package com.yicong.ants.view.dialog;

import android.content.Context;
import android.view.View;

import com.cchao.simplelib.Const;
import com.cchao.simplelib.core.Router;
import com.cchao.simplelib.core.UiHelper;
import com.yicong.ants.Constants;
import com.yicong.ants.R;
import com.yicong.ants.manager.UserManager;
import com.yicong.ants.ui.find.YcWebViewActivity;
import com.yicong.ants.ui.scenic.ScenicListActivity;
import com.yicong.ants.ui.video.VideoProfileActivity;
import com.yicong.ants.utils.DisplayUtils;

/**
 * 点击 【+ 蚁丛链接】弹出选项框，包含4个选项【商城商品，商城店铺，进入短视频主页，播放短视频】
 */
public class AntLinkDialog extends BaseNiceDialog implements View.OnClickListener {
    private static Context mContext;

    public static AntLinkDialog newInstance(Context context) {
        mContext = context;
        AntLinkDialog dialog = new AntLinkDialog();
        dialog.setWidth(DisplayUtils.px2dp(context, (float) (UiHelper.getScreenWidth() * 0.7)))
            .setOutCancel(true)
            .setDimAmount(0.3f);
        return dialog;
    }

    @Override
    public int intLayoutId() {
        return R.layout.dialog_ant_link;
    }

    @Override
    public void convertView(NiceViewHolder holder, BaseNiceDialog dialog) {
        holder.setOnClickListener(R.id.mall_store, this);
        holder.setOnClickListener(R.id.mall_product, this);
        holder.setOnClickListener(R.id.video_detail, this);
        holder.setOnClickListener(R.id.tv_video_profile, this);
        holder.setOnClickListener(R.id.scenic, this);
    }

    @Override
    public void onClick(View v) {
        dismiss();
        switch (v.getId()) {
            case R.id.scenic:
                Router.turnTo(mContext, ScenicListActivity.class)
                    .putExtra(Constants.Extra.Scenic_Type, Constants.Scenic_Type.SetPartnerAdvance)
                    .start();
                break;
            case R.id.mall_store:
            case R.id.mall_product:
                Router.turnTo(mContext, YcWebViewActivity.class)
                    .putExtra(Const.Extra.Web_View_Url,Constants.getWebUrl("mall"))
                    .putExtra(Const.Extra.Web_View_Tile, "蚁丛商城")
                    .putExtra(Const.Extra.Web_View_Title_Visible, false)
                    .checkLogin(true)
                    .start();
                break;
            case R.id.tv_video_profile:
            case R.id.video_detail:
                Router.turnTo(mContext, VideoProfileActivity.class)
                    .checkLogin(true)
                    .putExtra(Constants.Extra.Uid, UserManager.getUserId())
                    .start();
                break;
        }
    }
}
